package com.exp.collection;

import java.util.ArrayList;
import java.util.Collections;

class Employee implements Comparable<Employee>{
	int id;
	String Name;
	String Addr;
	char Gender;
	Double Sal;
	public Employee(int a,String b,String c,Double d,char e) {
		this.id = a;
		this.Name = b;
		this.Addr =c;
		this.Sal = d;
		this.Gender = e;
	}
	
	public String toString() {
		return ( this.Addr);
		
	}
	public String getAddr(){
		return this.Addr;
	}
	
	public void setAddr(String addr) {
		 this.Addr = addr;
	}
	@Override
	public int compareTo(Employee o) {
		// TODO Auto-generated method stub
		
		return Addr.compareTo(o.getAddr());
	}
}

public class EmployeeCollectionSort {
	
	public static void main(String[] args) {
		ArrayList<Employee> emp = new ArrayList<Employee>();
		emp.add(new Employee(10,"Jaya","Blore",20000.40,'f'));
		emp.add(new Employee(20,"maya","Mlore",25000.40,'f'));
		emp.add(new Employee(30,"liya","Hubli",200800.40,'m'));
		emp.add(new Employee(40,"geeya","Bangalore",29000.40,'m'));
		emp.add(new Employee(50,"Jaa","Blr",39000.40,'f'));
		System.out.println("Unsorted Address");
		System.out.println(emp);
		Collections.sort(emp);
		System.out.println("After Sort by Address" + emp);
	}
	
}
